use strict;
use warnings;

TEST('bsf edx, edi', [0x0f,0xbc,0xd7], 'MODE32');

TEST('bsr eax, ecx', [0x0f,0xbd,0xc1], 'MODE32');

TEST('bt edi, 2  ', [0x0f,0xba,0xe7,0x02], 'MODE32');
TEST('bt edi, 3  ', [0x0f,0xba,0xe7,0x03], 'MODE32');
TEST('bt ecx, 2  ', [0x0f,0xba,0xe1,0x02], 'MODE32');
TEST('bt ecx, 3  ', [0x0f,0xba,0xe1,0x03], 'MODE32');
TEST('bt rcx, rax', [0x48,0x0f,0xa3,0xc1], 'MODE64');
TEST('bt rdx, rax', [0x48,0x0f,0xa3,0xc2], 'MODE64');

TEST('movsx rax, r15b            ', [0x49,0x0f,0xbe,0xc7     ], 'MODE64');
TEST('movsx eax, byte [eax+edi+4]', [0x0f,0xbe,0x44,0x38,0x04], 'MODE32');
TEST('movsx ecx, cx              ', [0x0f,0xbf,0xc9          ], 'MODE32');
TEST('movsx eax, byte [eax+ecx+4]', [0x0f,0xbe,0x44,0x08,0x04], 'MODE32');
TEST('movsx ecx, cl              ', [0x0f,0xbe,0xc9          ], 'MODE32');
TEST('movsx eax, word [rax]      ', [0x0f,0xbf,0x00          ], 'MODE64');
TEST('movsx rax, byte [r8]       ', [0x49,0x0f,0xbe,0x00     ], 'MODE64');
TEST('movsx rax, r10b            ', [0x49,0x0f,0xbe,0xc2     ], 'MODE64');

TEST('movzx edi, si              ', [0x0f,0xb7,0xfe          ], 'MODE32');
TEST('movzx eax, word [ecx]      ', [0x0f,0xb7,0x01          ], 'MODE32');
TEST('movzx ecx, word [eax]      ', [0x0f,0xb7,0x08          ], 'MODE32');
TEST('movzx edi, word [ecx]      ', [0x0f,0xb7,0x39          ], 'MODE32');
TEST('movzx esi, word [edi]      ', [0x0f,0xb7,0x37          ], 'MODE32');
TEST('movzx eax, byte [ecx]      ', [0x0f,0xb6,0x01          ], 'MODE32');
TEST('movzx ecx, byte [eax]      ', [0x0f,0xb6,0x08          ], 'MODE32');
TEST('movzx edx, byte [ecx]      ', [0x0f,0xb6,0x11          ], 'MODE32');
TEST('movzx edi, al              ', [0x0f,0xb6,0xf8          ], 'MODE32');
TEST('movzx edi, byte [esi+1]    ', [0x0f,0xb6,0x7e,0x01     ], 'MODE32');
TEST('movzx edi, byte [esi+2]    ', [0x0f,0xb6,0x7e,0x02     ], 'MODE32');
TEST('movzx ecx, byte [esi+3]    ', [0x0f,0xb6,0x4e,0x03     ], 'MODE32');
TEST('movzx edi, byte [esi+5]    ', [0x0f,0xb6,0x7e,0x05     ], 'MODE32');
TEST('movzx edi, byte [esi+6]    ', [0x0f,0xb6,0x7e,0x06     ], 'MODE32');
TEST('movzx ecx, byte [esi+7]    ', [0x0f,0xb6,0x4e,0x07     ], 'MODE32');
TEST('movzx edi, byte [esi+9]    ', [0x0f,0xb6,0x7e,0x09     ], 'MODE32');
TEST('movzx edi, byte [esi+10]   ', [0x0f,0xb6,0x7e,0x0a     ], 'MODE32');
TEST('movzx ecx, byte [esi+11]   ', [0x0f,0xb6,0x4e,0x0b     ], 'MODE32');
TEST('movzx edi, byte [esi+13]   ', [0x0f,0xb6,0x7e,0x0d     ], 'MODE32');
TEST('movzx edi, byte [esi+14]   ', [0x0f,0xb6,0x7e,0x0e     ], 'MODE32');
TEST('movzx ecx, byte [esi+15]   ', [0x0f,0xb6,0x4e,0x0f     ], 'MODE32');
TEST('movzx edi, byte [esi+16]   ', [0x0f,0xb6,0x7e,0x10     ], 'MODE32');
TEST('movzx edi, byte [esi+17]   ', [0x0f,0xb6,0x7e,0x11     ], 'MODE32');
TEST('movzx edi, byte [esi+18]   ', [0x0f,0xb6,0x7e,0x12     ], 'MODE32');
TEST('movzx ecx, byte [esi+19]   ', [0x0f,0xb6,0x4e,0x13     ], 'MODE32');
TEST('movzx edi, byte [esi+21]   ', [0x0f,0xb6,0x7e,0x15     ], 'MODE32');
TEST('movzx edi, byte [esi+22]   ', [0x0f,0xb6,0x7e,0x16     ], 'MODE32');
TEST('movzx ecx, byte [esi+23]   ', [0x0f,0xb6,0x4e,0x17     ], 'MODE32');
TEST('movzx edi, byte [esi+25]   ', [0x0f,0xb6,0x7e,0x19     ], 'MODE32');
TEST('movzx edi, byte [esi+26]   ', [0x0f,0xb6,0x7e,0x1a     ], 'MODE32');
TEST('movzx ecx, byte [esi+27]   ', [0x0f,0xb6,0x4e,0x1b     ], 'MODE32');
TEST('movzx edi, byte [esi+29]   ', [0x0f,0xb6,0x7e,0x1d     ], 'MODE32');
TEST('movzx edi, byte [esi+30]   ', [0x0f,0xb6,0x7e,0x1e     ], 'MODE32');
TEST('movzx ecx, byte [esi+31]   ', [0x0f,0xb6,0x4e,0x1f     ], 'MODE32');
TEST('movzx edi, byte [esi-27]   ', [0x0f,0xb6,0x7e,0xe5     ], 'MODE32');
TEST('movzx edi, byte [esi-26]   ', [0x0f,0xb6,0x7e,0xe6     ], 'MODE32');
TEST('movzx ecx, byte [esi-25]   ', [0x0f,0xb6,0x4e,0xe7     ], 'MODE32');
TEST('movzx edi, byte [esi-23]   ', [0x0f,0xb6,0x7e,0xe9     ], 'MODE32');
TEST('movzx edi, byte [esi-22]   ', [0x0f,0xb6,0x7e,0xea     ], 'MODE32');
TEST('movzx ecx, byte [esi-21]   ', [0x0f,0xb6,0x4e,0xeb     ], 'MODE32');
TEST('movzx edi, byte [esi-19]   ', [0x0f,0xb6,0x7e,0xed     ], 'MODE32');
TEST('movzx edi, byte [esi-18]   ', [0x0f,0xb6,0x7e,0xee     ], 'MODE32');
TEST('movzx ecx, byte [esi-17]   ', [0x0f,0xb6,0x4e,0xef     ], 'MODE32');
TEST('movzx edi, byte [esi-15]   ', [0x0f,0xb6,0x7e,0xf1     ], 'MODE32');
TEST('movzx edi, byte [esi-14]   ', [0x0f,0xb6,0x7e,0xf2     ], 'MODE32');
TEST('movzx ecx, byte [esi-13]   ', [0x0f,0xb6,0x4e,0xf3     ], 'MODE32');
TEST('movzx edi, byte [esi-12]   ', [0x0f,0xb6,0x7e,0xf4     ], 'MODE32');
TEST('movzx edi, byte [esi-11]   ', [0x0f,0xb6,0x7e,0xf5     ], 'MODE32');
TEST('movzx edi, byte [esi-10]   ', [0x0f,0xb6,0x7e,0xf6     ], 'MODE32');
TEST('movzx ecx, byte [esi-9]    ', [0x0f,0xb6,0x4e,0xf7     ], 'MODE32');
TEST('movzx edi, byte [esi-7]    ', [0x0f,0xb6,0x7e,0xf9     ], 'MODE32');
TEST('movzx edi, byte [esi-6]    ', [0x0f,0xb6,0x7e,0xfa     ], 'MODE32');
TEST('movzx ecx, byte [esi-5]    ', [0x0f,0xb6,0x4e,0xfb     ], 'MODE32');
TEST('movzx edi, byte [esi-3]    ', [0x0f,0xb6,0x7e,0xfd     ], 'MODE32');
TEST('movzx edi, byte [esi-2]    ', [0x0f,0xb6,0x7e,0xfe     ], 'MODE32');
TEST('movzx ecx, byte [esi-1]    ', [0x0f,0xb6,0x4e,0xff     ], 'MODE32');
TEST('movzx edi, byte [esi-28]   ', [0x0f,0xb6,0x7e,0xe4     ], 'MODE32');
TEST('movzx ecx, byte [esi-26]   ', [0x0f,0xb6,0x4e,0xe6     ], 'MODE32');
TEST('movzx edi, byte [esi-24]   ', [0x0f,0xb6,0x7e,0xe8     ], 'MODE32');
TEST('movzx ecx, byte [esi-22]   ', [0x0f,0xb6,0x4e,0xea     ], 'MODE32');
TEST('movzx edi, byte [esi-20]   ', [0x0f,0xb6,0x7e,0xec     ], 'MODE32');
TEST('movzx ecx, byte [esi-18]   ', [0x0f,0xb6,0x4e,0xee     ], 'MODE32');
TEST('movzx edi, byte [esi-16]   ', [0x0f,0xb6,0x7e,0xf0     ], 'MODE32');
TEST('movzx ecx, byte [esi-14]   ', [0x0f,0xb6,0x4e,0xf2     ], 'MODE32');
TEST('movzx ecx, byte [esi-10]   ', [0x0f,0xb6,0x4e,0xf6     ], 'MODE32');
TEST('movzx edi, byte [esi-9]    ', [0x0f,0xb6,0x7e,0xf7     ], 'MODE32');
TEST('movzx edi, byte [esi-8]    ', [0x0f,0xb6,0x7e,0xf8     ], 'MODE32');
TEST('movzx ecx, byte [esi-6]    ', [0x0f,0xb6,0x4e,0xfa     ], 'MODE32');
TEST('movzx edi, byte [esi-4]    ', [0x0f,0xb6,0x7e,0xfc     ], 'MODE32');
TEST('movzx ecx, byte [esi-2]    ', [0x0f,0xb6,0x4e,0xfe     ], 'MODE32');
TEST('movzx edi, byte [esi-29]   ', [0x0f,0xb6,0x7e,0xe3     ], 'MODE32');
TEST('movzx ecx, byte [esi-27]   ', [0x0f,0xb6,0x4e,0xe5     ], 'MODE32');
TEST('movzx edi, byte [esi-25]   ', [0x0f,0xb6,0x7e,0xe7     ], 'MODE32');
TEST('movzx ecx, byte [esi-23]   ', [0x0f,0xb6,0x4e,0xe9     ], 'MODE32');
TEST('movzx edi, byte [esi-21]   ', [0x0f,0xb6,0x7e,0xeb     ], 'MODE32');
TEST('movzx ecx, byte [esi-19]   ', [0x0f,0xb6,0x4e,0xed     ], 'MODE32');
TEST('movzx edi, byte [esi-17]   ', [0x0f,0xb6,0x7e,0xef     ], 'MODE32');
TEST('movzx ecx, byte [esi-15]   ', [0x0f,0xb6,0x4e,0xf1     ], 'MODE32');
TEST('movzx edi, byte [esi-13]   ', [0x0f,0xb6,0x7e,0xf3     ], 'MODE32');
TEST('movzx ecx, byte [esi-11]   ', [0x0f,0xb6,0x4e,0xf5     ], 'MODE32');
TEST('movzx ecx, byte [esi-7]    ', [0x0f,0xb6,0x4e,0xf9     ], 'MODE32');
TEST('movzx edi, byte [esi-5]    ', [0x0f,0xb6,0x7e,0xfb     ], 'MODE32');
TEST('movzx ecx, byte [esi-3]    ', [0x0f,0xb6,0x4e,0xfd     ], 'MODE32');
TEST('movzx edi, byte [esi-31]   ', [0x0f,0xb6,0x7e,0xe1     ], 'MODE32');
TEST('movzx edi, byte [esi-30]   ', [0x0f,0xb6,0x7e,0xe2     ], 'MODE32');
TEST('movzx ecx, byte [esi-28]   ', [0x0f,0xb6,0x4e,0xe4     ], 'MODE32');
TEST('movzx ecx, byte [esi-24]   ', [0x0f,0xb6,0x4e,0xe8     ], 'MODE32');
TEST('movzx ecx, byte [esi-20]   ', [0x0f,0xb6,0x4e,0xec     ], 'MODE32');
TEST('movzx ecx, byte [esi-16]   ', [0x0f,0xb6,0x4e,0xf0     ], 'MODE32');
TEST('movzx ecx, byte [esi-12]   ', [0x0f,0xb6,0x4e,0xf4     ], 'MODE32');
TEST('movzx ecx, byte [esi-8]    ', [0x0f,0xb6,0x4e,0xf8     ], 'MODE32');
TEST('movzx ecx, byte [esi-4]    ', [0x0f,0xb6,0x4e,0xfc     ], 'MODE32');
TEST('movzx esi, byte [ecx]      ', [0x0f,0xb6,0x31          ], 'MODE32');
TEST('movzx ecx, byte [ecx+3]    ', [0x0f,0xb6,0x49,0x03     ], 'MODE32');
TEST('movzx ecx, byte [edx]      ', [0x0f,0xb6,0x0a          ], 'MODE32');
TEST('movzx ecx, byte [edx+1]    ', [0x0f,0xb6,0x4a,0x01     ], 'MODE32');
TEST('movzx ecx, byte [edx+2]    ', [0x0f,0xb6,0x4a,0x02     ], 'MODE32');
TEST('movzx edi, word [edx]      ', [0x0f,0xb7,0x3a          ], 'MODE32');
TEST('movzx ecx, word [esi]      ', [0x0f,0xb7,0x0e          ], 'MODE32');
TEST('movzx ecx, word [esi+edx]  ', [0x0f,0xb7,0x0c,0x16     ], 'MODE32');
TEST('movzx ebx, word [edi]      ', [0x0f,0xb7,0x1f          ], 'MODE32');
TEST('movzx ecx, word [ecx]      ', [0x0f,0xb7,0x09          ], 'MODE32');
TEST('movzx ecx, word [edx]      ', [0x0f,0xb7,0x0a          ], 'MODE32');
TEST('movzx ecx, cx              ', [0x0f,0xb7,0xc9          ], 'MODE32');
TEST('movzx ecx, ax              ', [0x0f,0xb7,0xc8          ], 'MODE32');
TEST('movzx ecx, al              ', [0x0f,0xb6,0xc8          ], 'MODE32');
TEST('movzx ecx, word [edi]      ', [0x0f,0xb7,0x0f          ], 'MODE32');
TEST('movzx edi, ax              ', [0x0f,0xb7,0xf8          ], 'MODE32');
TEST('movzx eax, word [ebx+edi]  ', [0x0f,0xb7,0x04,0x3b     ], 'MODE32');
TEST('movzx eax, word [edi]      ', [0x0f,0xb7,0x07          ], 'MODE32');
TEST('movzx ecx, word [ecx+eax*2]', [0x0f,0xb7,0x0c,0x41     ], 'MODE32');
TEST('movzx ecx, byte [edi]      ', [0x0f,0xb6,0x0f          ], 'MODE32');
TEST('movzx edi, word [eax+6]    ', [0x0f,0xb7,0x78,0x06     ], 'MODE32');
TEST('movzx edi, word [esi]      ', [0x0f,0xb7,0x3e          ], 'MODE32');
TEST('movzx edi, word [esi+2]    ', [0x0f,0xb7,0x7e,0x02     ], 'MODE32');
TEST('movzx eax, byte [eax+ecx]  ', [0x0f,0xb6,0x04,0x08     ], 'MODE32');
TEST('movzx edi, word [ecx+10]   ', [0x0f,0xb7,0x79,0x0a     ], 'MODE32');
TEST('movzx ecx, word [ebp-60]   ', [0x0f,0xb7,0x4d,0xc4     ], 'MODE32');
TEST('movzx edi, word [eax]      ', [0x0f,0xb7,0x38          ], 'MODE32');
TEST('movzx eax, word [r12]      ', [0x41,0x0f,0xb7,0x04,0x24], 'MODE64');
TEST('movzx edx, word [rax]      ', [0x0f,0xb7,0x10          ], 'MODE64');

TEST('shld eax, ecx, 11', [0x0f,0xa4,0xc8,0x0b], 'MODE32');

TEST('shrd eax, ecx, 4', [0x0f,0xac,0xc8,0x04], 'MODE32');

